import { method } from 'lodash';
import type { ApprovalData, ReviewAnnotationData } from 'typings/annotion/task';
import http from 'utils/http';

// 审核
export const auditTask = (data: ApprovalData) =>
    http({
        url: '/api/audit/subTask',
        data,
    });

// 初审保存标注内容
export const saveAuditTask = (data: any) =>
    http({
        url: '/api/task/saveAuditTask',
        data,
    });

// 复审保存标注内容
export const saveReviewTask = (data: any) =>
    http({
        url: '/api/task/saveReviewTask',
        data,
    });

// 获取任务图片信息
export const getTaskImageInfo = (subTaskId: number) =>
    http({
        url: `/api/image/statusInfo?subTaskId=${subTaskId}`,
    });

// 更新图片有效状态
export const updateImageStatus = (data: { imageId: number; imageStatus: 0 | 1 }) =>
    http({
        url: '/api/image/updateStatus',
        data,
    });

// 审核-保存修改标签
export const saveReviewLabel = (data: any) =>
    http({
        url: '/api/cvat/saveOrUpdateAnnontion',
        data,
    });

// 获取修改标签列表
export const getReviewAnnotationList = (jobId: number, subTaskId: number) =>
    http<any, ReviewAnnotationData>({
        url: `/api/cvat/getAuditAnnotion?jobId=${jobId}&subTaskId=${subTaskId}`,
    });

/**
 * 获取复审校验结果
 * @param jobId
 * @param subTaskId
 * @returns
 */
export const fetchLastReviewValid = (jobId: number | string, subTaskId: number | string) =>
    http<any, { valid: boolean; msg: string }>({
        url: `/api/audit/validTask?jobId=${jobId}&subTaskId=${subTaskId}`,
        method: 'post',
    });

// 创建图片标注任务
export const createTask = (taskId: string) =>
    http<
        any,
        {
            taskId: string;
            jobId: string;
        }
    >({
        url: `/api/label/createTask?taskId=${taskId}`,
    });
